#ifndef CAN_H
#define CAN_H

#include <FU68xx_6.h>

#define ENGINE_SPEED_MSG_ID (0x0cf00400) // 发动机转速报文 ID
#define MOTOR_CTRL_MSG_ID   (0x0cffa63d) // 控制指令报文   ID
#define AIR_TEMP_MSG_ID     (0x18fef500) // 大气温度报文   ID

/* IDE */
#define IDE_STD 0
#define IDE_EXT 0x80

/* RTR */
#define RTR_DAT 0
#define RTR_RMT 0x40

typedef struct
{
    uint8 ide;
    uint8 rtr;
    uint8 dlc;
    uint32 ext_id; // ID 范围 0-0x1FFFFFFF
    uint32 std_id; // ID 范围 0-0x7FF

    uint8 data0;
    uint8 data1;
    uint8 data2;
    uint8 data3;
    uint8 data4;
    uint8 data5;
    uint8 data6;
    uint8 data7;
} can_message_t;

extern can_message_t xdata can_receive_msg;
extern can_message_t xdata can_send_msg;

void can_read(void);
void can_send(void);
void can_init(void);
void update_can_feedback_message(void);

#endif
